package primetest.faces;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;


import primetest.dto.DepartmentDto;

public class DepartmentListModel extends ListDataModel<DepartmentDto> implements SelectableDataModel<DepartmentDto> {

	public DepartmentListModel(List<DepartmentDto> bookList){
		super(bookList);
	}

	@Override
	public DepartmentDto getRowData(String rowKey) {
		int bookSeq = Integer.valueOf(rowKey);
		@SuppressWarnings("unchecked")
		List<DepartmentDto> bookList = (List<DepartmentDto>)getWrappedData();
		for (DepartmentDto bookDto : bookList) {
			if(bookDto.getSeq() == bookSeq){
				return bookDto;
			}
		}
		return null;
	}

	@Override
	public Object getRowKey(DepartmentDto bookDto) {
		return bookDto.getSeq();
	}

}
